﻿/**
 * Copyright © 2010-2012 by Rob Cash
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *       http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Model.as
 */
package org.robcash.apps.flashcards.model
{
    import flash.events.*;
    import mx.events.*;

    public class Model implements ModelLocator
    {
        private static var instance:Model = null;
        private var _name:String;
        private var _gameManager:GameManager;
        private var _userScore:ScoreManager;
        private var _maxCounterValue:int;
        private var _counterAppliesToQuestion:Boolean = false;

        public static function getInstance() : Model
        {
            if (instance == null)
            {
                instance = new Model;
            }
            
            return instance;
        }

        public function Model()
        {
            if (instance != null)
            {
                throw new Error("Cannot instantiate Model directly. Use Model.getInstance() instead");
            }
            gameManager = new GameManager();
            userScore = new ScoreManager();
            maxCounterValue = 120;
        }

		[Bindable]
        public function get name() : String
        {
            return _name;
        }

        public function set name(name:String) : void
        {
        	_name = name;
        }

		[Bindable]
        public function get gameManager() : GameManager
        {
            return _gameManager;
        }// end function

        public function set gameManager(manager:GameManager) : void
        {
            _gameManager = manager;
        }

		[Bindable]
        public function get userScore() : ScoreManager
        {
            return _userScore;
        }

        public function set userScore(score:ScoreManager) : void
        {
        	_userScope = score;
        }

		[Bindable]
        public function get maxCounterValue() : int
        {
            return _maxCounterValue;
        }

        public function set maxCounterValue(param1:int) : void
        {
            _maxCounterValue = param1;
        }

		[Bindable]
        public function get counterAppliesToQuestion() : Boolean
        {
            return _counterAppliesToQuestion;
        }

        public function set counterAppliesToQuestion(applies:Boolean) : void
        {
            _counterAppliesToQuestion = applies;
        }

    }
}
